﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class AddStudent : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string sql = "insert into StudentInfo(stu_name,email,intro,password)" +
                " values(@name,@email,@intro,@password)";
            SqlParameter[] p =
            {
                new SqlParameter("@name",tbxName.Text),
                new SqlParameter("@email",tbxEmail.Text),
                new SqlParameter("@intro",tbxIntro.Text),
                new SqlParameter("@password",tbxPwd.Text)
            };
            int count = SqlHelper.ExecuteNonQuery(sql,p);
            if (count == 1)
            {
                Response.Write("<script>alert('添加成功')</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败')</script>");
            }
        }
    }
}